package cn.jr.service.impl;

import cn.jr.dao.IUserAndMoneyDao;
import cn.jr.dao.impl.UserAndMoneyDaoImpl;
import cn.jr.pojo.ShopRunAndMoney;
import cn.jr.service.IUserAndMoneyService;

import java.util.ArrayList;

public class UserAndMoneyServiceImpl implements IUserAndMoneyService {
    IUserAndMoneyDao iuamd=new UserAndMoneyDaoImpl();
    @Override
    public boolean xgUserAndMoney(String AccountId, Double AccountMoney) {
        return iuamd.updateUserAndMoney(AccountId,AccountMoney)>0?true:false;
    }

    @Override
    public boolean insertAccount(String AccountId) {
        return iuamd.insertAccount(AccountId)>0?true:false;
    }

    @Override
    public double queryAccountMoney() {
        /**
         * 查询所有用户金额总和
         * @return 所有用户金额总和
         */
        ArrayList<ShopRunAndMoney> list=iuamd.selectAccountMoney();
        double sum=0;
        for(ShopRunAndMoney s:list){
            sum+=s.getAccountMoney();
        }
        return sum;
    }
}
